/*
 * ItemTest.java
 *
 * This class uses the Item class to accept and display information about items
 * purchased and calculates the discount price.
 *
 * 
 */

package com.javacore.day9.store;

/**
 * ItemTest is a class used to generate an invoice for the items purchased.
 * @author 
 */
public class ItemTest {
    
    /**
     * Creates a new instance of ItemTest
     */
    public ItemTest() {
    }
    
    /**
     * This is the entry point of the application.
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        // Display the menu of items and their prices
        System.out.println("Welcome to Stationary Mart");
        System.out.format("%1$-15s %2$-15s\n","Item Name", "Item Price($)");
        System.out.format("%1$-15s %2$10.2f\n", "Pencil", 9.99);
        System.out.format("%1$-15s %2$10.2f\n", "Pen", 15.99);
        System.out.format("%1$-15s %2$10.2f\n", "Marker", 19.99);
        
        // Create an instance of Item class to purchase an item
        Item objItem1 = new Item();
        
        // Invoke a method to purchase an item
        objItem1.setDetails();
        
        // Calculate the discounted price for the item purchased
        objItem1.computePrice();
        
        // Change the discount percentage to 25%
        // for every item purchased henceforth
        Item.discount = 25;
        
        // Create an instance of Item class
        // to purchase another item
        Item objItem2 = new Item();
        objItem2.setDetails();
        objItem2.computePrice();
        
        // Change the discount percentage back to 20%
        // for every item purchased henceforth
        objItem2.discount = 20;
        
        // Create an instance of Item class
        // to purchase one more item
        Item objItem3 = new Item();
        objItem3.setDetails();
        objItem3.computePrice();
        
        // Display column headers for the invoice
        Item.displayHeader();
        
        // Display the details of items purchased  
        objItem1.displayDetails();
        objItem2.displayDetails();
        objItem3.displayDetails(); 
    }
}